﻿using PoemService.Shared;

namespace PoemGame.Domain.Services.Feihualing
{
    public class FeihualingCheckAnswerService : ICheckAnswerService
    {
        protected readonly IPoemService poemService;
        public FeihualingCheckAnswerService(IPoemService _poemService)
        {
            poemService = _poemService;
        }
        public virtual async Task<bool> CheckAnswer(CheckAnswerServiceInput game, string answer)
        {
            var targetWord = game.GameCondition;
            if (!await poemService.IsPoemLineExist(answer) || !answer.Contains(targetWord)) return false;
            var records = game.ProperAnswers;
            var record = records.Find(o => o == answer);
            return record == null;
        }
    }
}